<?php

class index {

    //使用模板类要使用use引入
    use \TempLets;

    public function main() {
        dump(Frame::RoutingData());
    }

    public function show() {
        $this->assign('data',['id' => 1, 'name' => 'shiroi']);
        $this->html(['show','index']);
    }

    public function request() {
        dump(Request::get());
        dump(Request::post());
        dump(Request::path());
        dump(Request::header());
        dump(Request::body());
        dump(Request::method());
        dump(Request::file());
        dump(Request::host());
        dump(Request::getip());
        dump(Request::localip());
        dump(Request::protocolversion());
        dump(Request::referer());
        dump(Request::scheme());
        dump(Request::uri());
    }

    public function thinkOrm() {
        $list = Model\User::newInstance()
            ->field(['id','unique_id','username','nickname','avatar'])
            ->select();
        //http打印
        var_dump($list);

        //控制台打印
        \Workerman\Lib\Timer::add(1,function () use ($list) {
            echo (new \MathieuViossat\Util\ArrayToTextTable(
                $list->toArray()
            ))->getTable();
        },[],false);
    }

    public function config() {
        dump(config('Mysql.connections.building.type','mysqli'));
    }

    public function curl() {
        //静态方法(参数请看类)
        dump((new Curl())
            ->url('https://baidu.com')
            ->save('baidu')
            ->exec());
    }

    public function globalSet()
    {

    }

    public function globalGet()
    {

    }
}
